# creational pattern（创建型）
# -> factory method pattern（工厂方法模式）
from abc import ABC, abstractmethod
##########################################
# 产品
class Button(ABC):
    @abstractmethod
    def on_click(self):
        pass

class WindowsButton(Button):
    def on_click(self):
        print('I\'m a WindowsButton')

class MacButton(Button):
    def on_click(self):
        print('I\'m a MacButton')

class LinuxButton(Button):
    def on_click(self):
        print('I\'m a LinuxButton')

##########################################
# 工厂
class Creator(ABC):
    @abstractmethod
    def createButton(self):
        pass

class WindowsCreator(Creator):
    def createButton(self):
        return WindowsButton()

class MacCreator(Creator):
    def createButton(self):
        return MacButton()

class LinuxCreator(Creator):
    def createButton(self):
        return LinuxButton()
##########################################
def main():
    creator = WindowsCreator()
    button = creator.createButton()
    button.on_click()

if __name__ == '__main__':
    main()